//
//  YWRuleTableViewCell.m
//  maintain
//
//  Created by Kyo on 16/8/4.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWRuleTableViewCell.h"
#import "YWMacro.h"
#import "UIColor+CustomColors.h"
#import "YWCommonTool.h"
#import "UIView+Extension.h"
#import "Masonry.h"

@interface YWRuleTableViewCell ()
@property (nonatomic, strong) UILabel *contenLabel;
@end

@implementation YWRuleTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"YWRuleTableViewCellIdentifier";
    YWRuleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[YWRuleTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(kMarginW, 12, SCREEN_WIDTH-kMarginW*2, kLabelH)];
        label.numberOfLines = 0;
        label.font = kContentFont;
        _contenLabel = label;
        [self.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(12);
            make.left.mas_equalTo(self.contentView.mas_left).offset(kMarginW);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-kMarginW);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-12);
        }];
    }
    return self;
}

- (void)setRuleContent:(NSString *)ruleContent{
    _ruleContent = ruleContent;
    self.contenLabel.text = ruleContent;
//    CGFloat height = [YWCommonTool getHeightOfLabel:ruleContent andWidth:SCREEN_WIDTH-kMarginW*2 andFont:kContentFont andMinHeight:kMinLabelH];
//    self.contenLabel.height = height;
}

//+ (CGFloat)cellHeightOfRuleContent:(NSString *)ruleContent{
//    CGFloat rowH = [YWCommonTool getHeightOfLabel:ruleContent andWidth:SCREEN_WIDTH-kMarginW*2 andFont:kContentFont andMinHeight:kMinLabelH];
//    return rowH + 12*2;
//}
@end
